import { GET_LIST_DATA } from './actionTypes'
import axios from 'axios'

export const contentList = obj => async (dispatch, getState) => {
  dispatch({
    type: 'SETLOADSTATE',
    obj: false
  });
  let url = './json/homelist.json'
  if (obj.filterData || getState().contentListReducer.filterData) {
    url = './json/listparams.json';
  }
  let resp = await axios({
    method: 'get',
    url: url
  })
  dispatch({
    type: GET_LIST_DATA,
    filterData: obj.filterData,
    toFirstPage: obj.toFirstPage,
    obj: resp.data
  })
  dispatch({
    type: 'SETLOADSTATE',
    obj: true
  });
}
